package cn.iocoder.yudao.module.engine.enums;

import cn.hutool.core.util.ArrayUtil;
import cn.iocoder.yudao.framework.common.core.StringArrayValuable;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

import java.util.Arrays;

/**
 * Node类型枚举
 */
@AllArgsConstructor
@ToString
public enum LiteFlowChainEnum implements StringArrayValuable {

    TEST_CHAIN("chain1", "测试Chain"),
    RULE_ENGINE("ruleEngine", "规则引擎Chain");

    public static final String[] ARRAYS = Arrays.stream(values())
            .map(LiteFlowChainEnum::getValue)
            .toArray(String[]::new);

    /**
     * 类型
     */
    private final String value;
    /**
     * 类型名
     */
    private final String name;

    public static LiteFlowChainEnum valueOf(Integer value) {

        return ArrayUtil.firstMatch(userType -> userType.getValue().equals(value), LiteFlowChainEnum.values());
    }

    @Override
    public String[] array() {
        return ARRAYS;
    }

    @JsonValue
    public String getValue() {
        return value;
    }

    public String getName() {
        return name;
    }
}
